/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.testis.utils.tree;

import org.testis.orm.classes.T_test_label;

/**
 * 
 * @author selcuk
 */
public class TristateLabelTreeNode extends LabelTreeNode {

    private TristateState m_tristate = TristateState.DESELECTED;

    public TristateLabelTreeNode(String name) {
	super(name);
    }

    public TristateLabelTreeNode(String name, TristateState state) {
	super(name);
	setState(state);
    }

    public TristateLabelTreeNode(T_test_label label) {
	super(label);
    }

    public TristateLabelTreeNode(T_test_label label, TristateState state) {
	super(label);
	setState(state);
    }

    @Override
    public boolean isSelected() {
	if (m_tristate == TristateState.SELECTED) {
	    return true;
	} else {
	    return false;
	}
    }

    @Override
    public void setSelected(boolean isSelected) {
	TristateState newState = TristateState.SELECTED;
	if (!isSelected) {
	    newState = TristateState.DESELECTED;
	}
	m_tristate = newState;
    }

    public boolean isIndeterminate() {
	if (m_tristate == TristateState.INDETERMINATE) {
	    return true;
	} else {
	    return false;
	}
    }

    public void setIndeterminate() {
	m_tristate = TristateState.INDETERMINATE;
    }

    public TristateState getState() {
	return m_tristate;
    }

    public void setState(TristateState state) {
	m_tristate = state;
    }
}
